package com.woniuxy.propertyjava.controller;


import com.woniuxy.propertyjava.entity.Holdinformation1;
import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.entity.Patrolplan;
import com.woniuxy.propertyjava.entity.ResponseResult;
import com.woniuxy.propertyjava.service.Holdinformation1Service;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Holdinformation1)表控制层
 *
 * @author makejava
 * @since 2022-07-06 09:59:23
 */
@RestController
@RequestMapping("holdinformation1")
public class Holdinformation1Controller {
    /**
     * 服务对象
     */
    @Resource
    private Holdinformation1Service holdinformation1Service;

    /**
     * 分页查询
     *
     * @param holdinformation1 筛选条件
     * @param pageIndex        分页对象
     * @return 查询结果
     */
    @GetMapping("/holdinformation1/{pageIndex}/{pageSize}")
    public ResponseResult<PageBean<Holdinformation1>> queryByPage(
            @RequestBody Holdinformation1 holdinformation1,
            @PathVariable int pageIndex,
            @PathVariable int pageSize) {
        PageBean<Holdinformation1> pageBean = new PageBean<>();

        pageBean=holdinformation1Service.queryByPage(holdinformation1,pageIndex,pageSize);
        ResponseResult<PageBean<Holdinformation1>> responseResult = new ResponseResult<>();
        responseResult.setCode(200);
        responseResult.setMsg("查询成功");
        responseResult.setData(pageBean);
        return responseResult;


    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/holdinformation/{id}")
    public ResponseResult<Holdinformation1> queryById(@PathVariable("id") Integer id) {
        return new ResponseResult<>(200,"ok",holdinformation1Service.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param holdinformation1 实体
     * @return 新增结果
     */
    @PostMapping("/holdinformation")
    public ResponseResult<Holdinformation1> add(@RequestBody Holdinformation1 holdinformation1) {
        return new ResponseResult<>(200,"ok",holdinformation1Service.insert(holdinformation1));
    }

    /**
     * 编辑数据
     *
     * @param holdinformation1 实体
     * @return 编辑结果
     */
    @PutMapping("/holdinformation")
    public ResponseResult<Holdinformation1> edit(@RequestBody Holdinformation1 holdinformation1) {
        return new ResponseResult<>(200,"ok",holdinformation1Service.update(holdinformation1));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/holdinformation")
    public ResponseResult<Boolean> deleteById(Integer id) {
        return new ResponseResult<>(200,"ok",holdinformation1Service.deleteById(id));
    }

}

